<template>
  <view class="location">
    <view slot="center">
      <view class="search_box">
        <u-search :showAction="false" placeholder="日照香炉生紫烟" v-model="keyword"></u-search>
      </view>
    </view>
    <u-index-list :index-list="indexList">
      <template v-for="(item, index) in itemArr">
        <u-index-item>
          <!-- #ifndef APP-NVUE -->
          <u-index-anchor :text="indexList[index]"></u-index-anchor>
          <!-- #endif -->
          <!-- {{item.city}} -->
          <view class="list-cell" v-for="(cell, index) in item.city">
            {{cell.name}}
          </view>
        </u-index-item>
      </template>
    </u-index-list>
  </view>
</template>

<script>
  import {
    cityData
  } from '@/api/city.js'
  export default {
    computed: {
      indexList() {
        return cityData.map(item => item.index)
      }
    },
    data() {
      return {
        keyword: '',
        // indexList: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
        //   "U", "V", "W", "X", "Y", "Z"
        // ],
        itemArr: cityData
      }
    },
    onLoad() {
      console.log(cityData, 'cityData')
    }
  }
</script>

<style lang="scss">
  .search_box {
    width: 642rpx;
    margin-left: 36rpx;
  }

  .list-cell {
    display: flex;
    box-sizing: border-box;
    width: 100%;
    padding: 10px 24rpx;
    overflow: hidden;
    color: #323233;
    font-size: 14px;
    line-height: 24px;
    background-color: #fff;
  }
</style>